package com.dstation.service;

import com.dstation.dao.DynamicInfoMapper;
import com.dstation.domain.DynamicInfo;
import com.dstation.service.interf.IDynamicService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.List;

/**
 * @author Eastward
 * @date 2022/5/19 - 10:28
 */
@Service
public class DynamicServiceImpl implements IDynamicService {
    @Resource
    private DynamicInfoMapper dynamicInfoMapper;
    @Override
    public boolean addDynamicInfo(DynamicInfo dynamicInfo) {
        return dynamicInfoMapper.insertDynamicInfo(dynamicInfo);
    }

    @Override
    public List<DynamicInfo> findAllDynamicInfo() {
        return dynamicInfoMapper.selectAllDynamicInfo();
    }

    @Override
    public boolean dropDynamicInfo(long dynamicId) {
        return dynamicInfoMapper.deleteDynamicInfo(dynamicId);
    }

    @Override
    public DynamicInfo queryDynamicInfoByDynamicId(long dynamicId) {
        return dynamicInfoMapper.selectDynamicInfoByDynamicId(dynamicId);
    }

    @Override
    public boolean addUserPraiseDynamicInfo(long dynamicId, Long userId, Timestamp createDate) {
        return dynamicInfoMapper.insertUserPraiseDynamicInfo(dynamicId,userId,createDate);
    }

    @Override
    public boolean dropUserPraiseDynamicInfo(long dynamicId, Long userId) {
        return dynamicInfoMapper.deleteUserPraiseDynamicInfo(dynamicId,userId);
    }

    @Override
    public long findPraiseNumByDynamicId(long dynamicId) {
        return dynamicInfoMapper.selectPraiseNumByDynamicId(dynamicId);
    }

    @Override
    public int findUserIsPraiseByDynamicId(long dynamicId, long userId) {
        return dynamicInfoMapper.selectUserIsPraiseByDynamicId(dynamicId,userId);
    }

    @Override
    public boolean alterDynamicInfo(DynamicInfo dynamicInfo) {
        return dynamicInfoMapper.updateDynamicInfo(dynamicInfo);
    }
}
